package com.github.thinwonton.spring.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.github.thinwonton.spring.annotation.AvoidMultipalSubmit;
import com.github.thinwonton.spring.entity.User;

@Controller
public class UserController {

	/**
	 * 保存用户信息
	 * 
	 * @param user
	 * @return
	 */
	@AvoidMultipalSubmit(avoid = true)
	@RequestMapping(value = "/user", method = RequestMethod.POST)
	public String saveUser(User user) {
		System.out.println("save user -->" + user.toString());
		return "redirect:/page/user/ok"; //返回保存成功的页面
	}

	/**
	 * 返回用户页面
	 * 
	 * @return
	 */
	@AvoidMultipalSubmit(preHandle = true)
	@RequestMapping(value = "/page/user")
	public String userPage() {
		return "user";
	}
	
	/**
	 * 返回保存用户OK页面
	 * 
	 * @return
	 */
	@RequestMapping(value = "/page/user/ok")
	public String okPage() {
		return "ok";
	}
}
